# Contributor: Martell Malone <martell malone at gmail dot com>

_realname=glew
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=1
arch=('any')
pkgdesc="GLEW, The OpenGL Extension Wrangler Library (mingw-w64)"
depends=()
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "xz")
license=('Modified BSD/MIT/GPL')
url="http://glew.sourceforge.net/"
options=('strip' '!libtool' 'staticlibs')
source=("https://sourceforge.net/projects/glew/files/glew/${pkgver}/${_realname}-${pkgver}.tgz"
        001-makefile.patch)
sha256sums=('c572c30a4e64689c342ba1624130ac98936d7af90c3103f9ce12b8a0c5736764'
            '3a31defa67e42c0ae7d54a4056391f7f8436627f5b462ba663fa2a82c1b6ccab')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-makefile.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -rf "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}" && \
     cd "${srcdir}/build-${MINGW_CHOST}"
  MSYSTEM=MINGW make GLEW_PREFIX=${MINGW_PREFIX}
}

package () {
  cd "${srcdir}/build-${MINGW_CHOST}"
  MSYSTEM=MINGW make GLEW_PREFIX=${MINGW_PREFIX} DESTDIR="${pkgdir}" install.all
}
